package com.chinasofti.project.service.user.impl;

import javax.mail.MessagingException;

import org.springframework.stereotype.Service;

import com.chinasofti.project.common.MailUtil;
import com.chinasofti.project.service.user.MailService;

@Service("mailService")
public class MailServiceImpl implements MailService
{
	 private  String resetPasswordMailContent="<!DOCTYPE html>\n" +
	            "<html lang=\"en\">\n" +
	            "<head>\n" +
	            "    <meta charset=\"UTF-8\">\n" +
	            "    <title>验证码邮件</title>\n" +
	            "    <style>\n" +
	            "        body{\n" +
	            "            background: #eee;\n" +
	            "            font-family: \"微软雅黑\",\"tahoma\",\"Helvetica Neue\";\n" +
	            "            font-size:16px;\n" +
	            "            color:#333;\n" +
	            "        }\n" +
	            "        #greeting{\n" +
	            "\n" +
	            "        }\n" +
	            "        #content{\n" +
	            "            padding-left:2em ;\n" +
	            "        }\n" +
	            "        #sign{\n" +
	            "            padding-top: 2em;\n" +
	            "            padding-left: 30em;\n" +
	            "        }\n" +
	            "    </style>\n" +
	            "</head>\n" +
	            "<body>\n" +
	            "<p id=\"greeting\">%s，</p>\n" +
	            "<br/>\n" +
	            "<div id=\"content\">您在我们的微风商城的邮件验证码为：<code>%s<code>,请妥善保管!\uD83D\uDE0A</div>\n" +
	            "<div id=\"sign\">微风小机器人</div>\n" +
	            "</body>\n" +
	            "</html>";


	    @Override
	    public void sendResetPasswordMail(String to,String code) {
	      	String content = String.format(resetPasswordMailContent,to,code);
	        try {
	            MailUtil.send(to,"微风邮件验证码",content);
	        } catch (MessagingException e) {
	            throw new RuntimeException(e);
	        }

	    }
}
